import java.util.ArrayList;
import java.util.List;

public class Test2 {
    public static void main(String[] args) {
        subsets(new int[]{1,2,3});
    }

    static List<List<Integer>> ret = new ArrayList<>();
    static List<Integer> path = new ArrayList<>();
    public static List<List<Integer>> subsets(int[] nums) {

        dfs(nums, 0);
        return ret;
    }
    public static void dfs(int[] nums, int index) {
        if(index == nums.length) {
//            ret.add(path);
            ret.add(new ArrayList<>(path));
            return;
        }

        dfs(nums, index + 1);

        path.add(nums[index]);
        dfs(nums, index + 1);
        path.remove(path.size() - 1);
    }
}
